package cn.com.greatwall.flowable.service;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.data.domain.Pageable;

import cn.com.greatwall.flowable.service.dto.CommentDto;
import cn.com.greatwall.flowable.service.dto.ProcessInstanceDetailDto;
import cn.com.greatwall.flowable.service.dto.ProcessInstanceDto;
import cn.com.greatwall.flowable.service.dto.criteria.ProcessInstanceQueryCriteria;

/**
 * @Author herw
 * @Time 2020-11-23 16:52:15
 * @Version 1.0
 * @Description: TODO(用一句话描述该文件做什么)
 */
public interface ProcessInstanceService {
    /**
     * 分页查询
     * 
     * @param criteria 条件
     * @param pageable 分页参数
     * @return /
     */
    Map<String, Object> queryAll(ProcessInstanceQueryCriteria criteria, Pageable pageable);
    
    /**
     * 根据ID查询
     * 
     * @param id
     * @return
     * @throws UnsupportedEncodingException
     */
    ProcessInstanceDetailDto findById(String processInstanceId);
    
    /**
     * 查询单一流程实例
     *
     * @param processInstanceId
     * @return
     */
    ProcessInstance getProcessInstanceById(String processInstanceId);
    
    /**
     * 查询单一历史流程实例
     *
     * @param processInstanceId
     * @return
     */
    HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);
    
    /**
     * 启动流程实例
     * 
     * @param dto
     */
    void start(ProcessInstanceDto dto);
    
    /**
     * 删除流程实例
     *
     * @param processInstanceId
     * @param cascade
     * @param reason
     */
    void delete(String processInstanceId, boolean cascade, String reason);
    
    /**
     * 激活流程实例
     *
     * @param processInstanceId
     */
    void activate(String processInstanceId);
    
    /**
     * 挂起流程实例
     *
     * @param processInstanceId
     */
    void suspend(String processInstanceId);
    
    /**
     * 获取审核意见
     * 
     * @param processInstanceId
     */
    List<CommentDto> comments(String processInstanceId);
}
